/**
 * @file gc9a01_test.c
 * @author WaterFairy
 * @brief
 * @version 1.0.0
 * @date 2024-06-27 23:06:34
 *
 * @copyright Copyright (c) 2024
 *
 */

#include <stdio.h>
#include <fcntl.h>      //O_RDWR
#include <unistd.h>     //open write read
#include <string.h>
#include <time.h>


#include "gc9a01_test.h"
#include "image.h"

 /**
  * @brief 写字符设备
  *
  */
int gc9a01_test_show_image(void) {


    int fd;



    fd = open("/dev/spiScreenDevice", O_RDWR);

    if (fd == -1)
    {
        printf("open error!");
        return -1;
    }


    //最大写4096字节
    char* image_from = image_a + 4;


    unsigned int current_index = 0;
    unsigned int len = 0;
    while (1)
    {


        len = 115200 - current_index;
        if (len > 4096)
        {
            len = 4096;
        }

        printf("%d %d\n", current_index, len);
        write(fd, image_from + current_index, len);
        current_index += len;
        if (len < 4096)
        {
            break;
        }
    }

    close(fd);

    return 0;
}
